package com.tianzeculture.stagebao.activity.home.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tianzeculture.stagebao.R;

import java.util.List;

/**
 * Created by Administrator on 2018/6/4 0004.
 */

public class SearchFireAdapter extends BaseAdapter {
    Context context;
    List<String> strings;

    public SearchFireAdapter(Context context, List<String> strings) {
        this.context = context;
        this.strings = strings;
    }

    @Override
    public int getCount() {
        return strings.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.item_search_fire, null);
            holder.tvFire = view.findViewById(R.id.tvFire);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        setData(holder, i);
        return view;
    }

    private void setData(ViewHolder holder, int i) {
        holder.tvFire.setText(strings.get(i));
        if (i / 3 == 0)
            holder.tvFire.setBackgroundResource(R.drawable.bg_lightpink_transparent_round);
        else if (i / 3 == 1)
            holder.tvFire.setBackgroundResource(R.drawable.bg_lightpurple_transparent_round);
        else if (i / 3 == 2)
            holder.tvFire.setBackgroundResource(R.drawable.bg_lightorange_transparent_round);
        else
            holder.tvFire.setBackgroundResource(R.drawable.bg_lightgreen_transparent_round);
    }

    private class ViewHolder {
        TextView tvFire;
    }
}




